package demo;


import demo.standard.Caretaker;
import demo.standard.Memento;
import demo.standard.Originator;

public class ClientForStandard {

    public static void main(String[] args) {

        Caretaker caretaker = new Caretaker();

        Originator originator = new Originator("", "初始状态");
        Memento memento = originator.createMemento();
        caretaker.add(memento);
        System.out.println("对originator创建备忘录:" + memento);

        originator.setId("1");
        originator.setState("新状态");
        System.out.println("当前originator：" + originator);

        originator.restore(caretaker.undo());
        System.out.println("恢复后originator：" + originator);
    }
}
